package com.bloody.android.Characters;

import android.os.Bundle;
import android.util.Log;

import com.bloody.android.BloodyCrusadeGame;
import com.bloody.android.Map.Map;

public class GaaraAbility extends SpecialAbility{
	
	private int attack;
	
	public GaaraAbility(Map map, int attack){
		super("Sabaku", map);
		this.attack=attack;
		int [] attackRange;
		attackRange = new int[2];
		for (int i= 0; i<attackRange.length; i++)
			attackRange[i]=i+1;
		super.setRange(attackRange);		
	}
	
	public Bundle effect(BloodyCrusadeGame bcg, int level){
		int otherPosX = bcg.getPositionX();
		int otherPosY = bcg.getPositionY();
		Character attacked = super.getMap().getCharacter(otherPosX, otherPosY);
		
		int dommage=0;
		if(level==1)
			dommage = Math.max(10, (attack/2)+(200-super.getCharacter().getLife())*4/19);
		else if(level==2)
		{
			dommage = Math.max(10, attack+(200-super.getCharacter().getLife())*4/19);
			((Gaara)super.getCharacter()).switchProtection();
		}

		attacked.hurt(dommage);//SPECIAL
		
		Bundle bundle = new Bundle();
		bundle.putSerializable("giver", super.getCharacter());
		bundle.putSerializable("receiver", attacked);
		bundle.putInt("dommage", dommage);
		bundle.putString("name", super.getName());
			Log.d("DEBUG", ""+attacked+" "+bcg.getCharacter(false, attacked.getID()));
			Log.d("DEBUG", ""+bcg.getCharacter(true, attacked.getID()));
		
		return bundle;
	}
	
	
}
